<?php

namespace app\api\controller\company;
use app\api\model\Company;
use app\common\controller\Api;
class index extends Api
{

    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    /**
     * 公司注册
     */
    public function register(){
        if ($this->request->isPost()){
            $data = $this->request->post();

            if(!isset($data['phone']) || $data['phone'] == '') $this->error('手机号码不能为空');
            if(!isset($data['hotelname']) || $data['hotelname'] == '') $this->error('酒店名字不能为空');
            if(!isset($data['validstarttime']) || $data['validstarttime'] == '') $this->error('有效期不能为空');
            if(!isset($data['validendtime']) || $data['validendtime'] == '') $this->error('有效期不能为空');
            if (!isset($_FILES['Yyzzimages']) || $_FILES['Yyzzimages'] == '') $this->error('营业执照不能为空');
            $file = $this->request->file('Yyzzimages');
            $info = $file->move(ROOT_PATH.'public'.DS.'uploads');
            if ($filename = $info->getFilename()){
                $data['Yyzzimages'] = '\uploads' .DS. $info->getSaveName();
                $model = new Company();
                if ($model->add($data)){
                    $this->success('提交成功，等待平台审核');
                }else{
                    $this->error($model->getError());
                }
            }else{
                $this->error('提交失败');
            }
        }

    }


    public function login(){

    }

}